package day06;
import static day06.CarFactory.*;
import static day06.ShapeFactory.SQUARE;
import static day06.ShapeFactory.getShape;

import java.util.Scanner;

public class TestCar {
public static void main(String[] args) {
//	Scanner sc =new Scanner(System.in);
//	int scs =sc.nextInt();
	//创建业务类对象
	CarService ss = new CarService();
	//提供需要计算的汽车(面向父类编程--编译时类型写成父类)
//	Car s = new BigCar(2014);
//	System.out.println("汽车单价"+ss.getDanJia(s));
//	System.out.println("汽车总价"+ss.getTotalPrice(s));
	//利用工厂模式创建子类对象
	//Car  s = CarFactory.getCar(SQUARE);
			//使用静态导入import static day06.ShapeFactory.*;  简化得到如下结果
	Car s =  getCar(SMALLCAR);
	//Car s =  getCar(BIGCAR);
	if (s instanceof BigCar) {
		BigCar bigcar = (BigCar) s;
		bigcar.setYear(1024);
		System.out.println(ss.getDanJia(s));
	} else {
		SmallCar smallcar = (SmallCar) s;
		smallcar.setYear(2014);
		System.out.println(ss.getTotalPrice(s));
	}
}

}
